﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace LostHobbits.Sound
{
    public class SoundManager : GameComponent, ISoundService
    {
        Dictionary<SoundType, SoundEffect> sounds;

        public SoundManager(Game game)
            : base(game)
        {
            game.Services.AddService(typeof(ISoundService), this); 
            sounds = new Dictionary<SoundType, SoundEffect>();
            sounds.Add(SoundType.FoscoJamp, game.Content.Load<SoundEffect>("Content/Sounds/Fosco jump"));                      
            
        }

        public void Play(SoundType soundType)
        {
            sounds[soundType].Play();
        }
        /// <summary>
        /// Pauses or resumes all sounds. To be used at game pause and resume.
        /// </summary>
        public void PauseOrResumeAll()
        {

            foreach (KeyValuePair<SoundType, SoundEffect> kvp in sounds)
            {
                /*
                if (kvp.Value.IsPaused)
                {
                    kvp.Value.Resume();
                }
                else if (kvp.Value.IsPlaying)
                {
                    kvp.Value.Pause();
                }
                 * */
            }

        }
    }
}
